Skip to content

resolve: Catch "cannot reexport" errors from macros 2.0 better#156014

Merged
rust-bors[bot] merged 4 commits intorust-lang:mainfrom
petrochenkov:kvak
May 5, 2026
Merged

resolve: Catch "cannot reexport" errors from macros 2.0 better#156014
rust-bors[bot] merged 4 commits intorust-lang:mainfrom
petrochenkov:kvak

Conversation

@petrochenkov
Copy link
Copy Markdown
Contributor

After the macro 2.0 related holes are closed we can report span_delayed_bugs in more situations.

Merging #155945 would make changes in this PR simpler, but that PR will probably have to wait for quite some time.

This is a continuation of my import & privacy invariant hardening changes from #155257, #155213, #154149, etc.

r? @mu001999

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 30, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_resolve/src/imports.rs
@petrochenkov
Copy link
Copy Markdown
Contributor Author

error[E0365]: extern crate `rustc_abi` is private and cannot be re-exported
  --> src/tools/rust-analyzer/crates/hir-def/src/lib.rs:50:9
   |
50 | pub use rustc_abi as layout;
   |         ^^^^^^^^^^^^^^^^^^^
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #127909 <https://github.com/rust-lang/rust/issues/127909>
   = note: `#[deny(pub_use_of_private_extern_crate)]` (part of `#[deny(future_incompatible)]`) on by default
help: consider making the `extern crate` item publicly accessible
   |
18 | pub extern crate ra_ap_rustc_abi as rustc_abi;
   | +++

Hmm, legitimate pub_use_of_private_extern_crate error in rust-analyzer, I wonder why it wasn't caught before.

Comment thread tests/ui/imports/private-from-decl-macro.fail.stderr
@mu001999
Copy link
Copy Markdown
Member

mu001999 commented May 1, 2026

lgtm, but I also wonder why the error in ra was not caught before. Seems it just one simple case of the lint.

@rust-bors

This comment has been minimized.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

I'll look what's going on with rust-analyzer.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 1, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

The problem is in rustc_abi specifically.
There's actually a built-in attribute with this name, so the pub use rustc_abi as layout; import legally reexports at least the built-in attribute, that's why the logic in finalize_import didn't report it.

So the import itself won't be an error when the pub_use_of_private_extern_crate lint is removed, the private extern crate component in type namespace will just be filtered away.
Users of the reexport will break though, because they definitely wan the crate, not the attribute, so we need to lint this case in advance.

@rustbot rustbot added the T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. label May 4, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

rust-analyzer is developed in its own repository. If possible, consider making this change to rust-lang/rust-analyzer instead.

cc @rust-lang/rust-analyzer

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 4, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@petrochenkov
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 4, 2026
Copy link
Copy Markdown
Member

@mu001999 mu001999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 5, 2026

📌 Commit fadb747 has been approved by mu001999

It is now in the queue for this repository.

@rust-bors rust-bors Bot added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label May 5, 2026
@rust-bors rust-bors Bot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 5, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request May 5, 2026
resolve: Catch "cannot reexport" errors from macros 2.0 better

After the macro 2.0 related holes are closed we can report `span_delayed_bug`s in more situations.

Merging rust-lang#155945 would make changes in this PR simpler, but that PR will probably have to wait for quite some time.

This is a continuation of my import & privacy invariant hardening changes from rust-lang#155257, rust-lang#155213, rust-lang#154149, etc.

r? @mu001999
rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
Rollup of 3 pull requests

Successful merges:

 - #154861 (Add rlib digest to identify Rust object files)
 - #155341 (generic_const_args: allow paths to non type consts)
 - #156014 (resolve: Catch "cannot reexport" errors from macros 2.0 better)
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 5, 2026
resolve: Catch "cannot reexport" errors from macros 2.0 better

After the macro 2.0 related holes are closed we can report `span_delayed_bug`s in more situations.

Merging rust-lang#155945 would make changes in this PR simpler, but that PR will probably have to wait for quite some time.

This is a continuation of my import & privacy invariant hardening changes from rust-lang#155257, rust-lang#155213, rust-lang#154149, etc.

r? @mu001999
rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #156014 (resolve: Catch "cannot reexport" errors from macros 2.0 better)
 - #156058 (Print HRTB binders before fn qualifiers)
 - #156172 (Implement a new flag `-Zdisable-fast-paths` in trait solving)
 - #156184 (Revert "remove `MethodReceiverExpr` special-casing")
 - #155957 (Revert const hacks and use const closures in std)
 - #156127 (Update `askama` version to `0.16.0`)
 - #156183 (Remove duplicate debug assert)
rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #156014 (resolve: Catch "cannot reexport" errors from macros 2.0 better)
 - #156058 (Print HRTB binders before fn qualifiers)
 - #156172 (Implement a new flag `-Zdisable-fast-paths` in trait solving)
 - #156184 (Revert "remove `MethodReceiverExpr` special-casing")
 - #155957 (Revert const hacks and use const closures in std)
 - #156127 (Update `askama` version to `0.16.0`)
 - #156183 (Remove duplicate debug assert)
rust-bors Bot pushed a commit that referenced this pull request May 5, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #156014 (resolve: Catch "cannot reexport" errors from macros 2.0 better)
 - #156058 (Print HRTB binders before fn qualifiers)
 - #156172 (Implement a new flag `-Zdisable-fast-paths` in trait solving)
 - #156184 (Revert "remove `MethodReceiverExpr` special-casing")
 - #155957 (Revert const hacks and use const closures in std)
 - #156127 (Update `askama` version to `0.16.0`)
 - #156183 (Remove duplicate debug assert)
@rust-bors rust-bors Bot merged commit e35334f into rust-lang:main May 5, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone May 5, 2026
rust-timer added a commit that referenced this pull request May 5, 2026
Rollup merge of #156014 - petrochenkov:kvak, r=mu001999

resolve: Catch "cannot reexport" errors from macros 2.0 better

After the macro 2.0 related holes are closed we can report `span_delayed_bug`s in more situations.

Merging #155945 would make changes in this PR simpler, but that PR will probably have to wait for quite some time.

This is a continuation of my import & privacy invariant hardening changes from #155257, #155213, #154149, etc.

r? @mu001999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants